<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/5/17
  Time: 15:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8"
         isELIgnored="false" language="java" %>
<html>
<head>
  <title>注册页面</title>
  <script src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
<%--  <script src="/js/jquery-3.3.1.js"></script>--%>
  <%--<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>--%>
  <script>
    function togo(){
      //alert(1)
      var username = $("#name").val().trim();
      var password = $("#password").val().trim();
      var cpwd =$("#cpwd").val().trim();
      $.post({
        url:"${pageContext.request.contextPath}/user/register",
        data:{
          "username":username,
          "password":password,
          "confirmPwd":cpwd
        },
        success:function (data) {
          alert(data);
          if(data=="success"){
            window.location.href="http://localhost:8080/user/toLogin";
          }else{
            $("#errorMsg").css("color","red");
            $("#errorMsg").html(data);
          }
        }
      });
    }
  </script>
</head>
<body>
<form>
  <table>
    <tr>
      <td>用户名：</td>
      <td>
        <input id="name" type="text" name="username" clas="textSize">
      </td>
    </tr>
    <tr>
      <td>密码：</td>
      <td>
        <input id="password" type="password" name="password" clas="textSize">
      </td>
    </tr>
    <tr>
      <td>确认密码：</td>
      <td>
        <input id="cpwd" type="password" name="confirmPwd" clas="textSize">
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <input type="button" value="注册" onclick="togo()">
        <span id="errorMsg"></span>
      </td>
    </tr>
  </table>
</form>
</body>
</html>